import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';

//注意， 要导入Http模块
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';

/*
  Generated class for the StorageProvider provider.

  See https://angular.io/guide/dependency-injection for more info on providers
  and Angular DI.
  保存历史记录的服务
*/
@Injectable()
export class StorageProvider {

  constructor(public http: HttpClient) {
    console.log('Hello StorageProvider Provider');
  }

  //localStorage
  //存
  set(key,value){
    localStorage.setItem(key,JSON.stringify(value));  //对象转成字符串
  }

  //取
  get(key){
    return JSON.parse(localStorage.getItem(key));   //字符串转对象
  }

  //移除
  remove(key){
    localStorage.removeItem(key);
  }


}
